package CodeOne;

import java.util.HashMap;
import java.util.Scanner;

/** @author ASUS */
public class FindFriends {
  public static void main(String[] args) {
    Scanner inputScanner = new Scanner(System.in);
    String str;
    str = inputScanner.nextLine();
    String[] parts = str.split(" ");
    int n = Integer.parseInt(parts[0]);
    HashMap<String, Integer> map = new HashMap<>(n);
    String[] nums = new String[n];
    for (int i = 0; i < n; i++) {
      nums[i] = inputScanner.nextLine();
      if (map.containsKey(nums[i])) {
        map.put(nums[i], map.get(nums[i]) + 1);
      } else {
        map.put(nums[i], 0);
      }
    }
    for (int i = 0; i < n; i++) {
      int f = map.get(nums[i]);
      if (f == 0) {
        System.out.println("BeiJu");
      } else {
        System.out.println(f);
      }
    }
  }
}
